<?php
require 'cms/models/Content.php';

require 'cms/models/Category.php';

class Cms_ContentController extends Zend_Controller_Action
{

	public function indexAction()
	{
		$this->_forward('test1');
	}

	public function testAction()
	{
		$contentModel = new Content();
		
		$categoryModel = new Category();
		
		$category = $categoryModel->createRow();
		$category->setName('New Category 6');

		$content = $contentModel->createRow();
		$content->setTitle('Title 10');
		$content->setContent('Content 10');
		$content->setIsActive(1);
		
		$content2 = $contentModel->createRow();
		$content2->setTitle('Title 11');
		$content2->setContent('Content 11');
		$content2->setIsActive(0);

		$category->addContent($content);
		$category->addContent($content2);

		$category->save();


		print '<pre>';
		var_dump($category->getData());
		die;
	}
	
	public function test7Action()
	{
		$contentModel = new Content();
		
		$categoryModel = new Category();
		
		$category = $categoryModel->findById(3);

		$content = $contentModel->createRow();
		$content->setTitle('Title 8');
		$content->setContent('Content 8');
		$content->setIsActive(1);
		
		$content2 = $contentModel->createRow();
		$content2->setTitle('Title 9');
		$content2->setContent('Content 9');
		$content2->setIsActive(0);

		$category->addContent($content);
		$category->addContent($content2);

		$category->save();


		print '<pre>';
		var_dump($category->getData());
		die;
	}
	
	public function test6Action()
	{
		$contentModel = new Content();
		
		$content = $contentModel->findById(5);
		$coll = $content->getCategory()->getName();
		
		print '<pre>';
		var_dump($coll);
		die;
	}
	
	public function test5Action()
	{		
		$categoryModel = new Category();
		
		$category = $categoryModel->findById(4);
		$coll = $category->getContents();
		
		print '<pre>';
		var_dump($coll);
		die;
	}

	public function test4Action()
	{
		$contentModel = new Content();
		
		$categoryModel = new Category();
		
		$category = $categoryModel->findById(4);

		$content = $contentModel->createRow();
		$content->setTitle('Title 7');
		$content->setContent('Content 7');
		$content->setIsActive(1);

		$category->setContent($content);

		$category->save();

		print '<pre>';
		var_dump($category->getData());
		die;
	}

	public function test3Action()
	{
		$contentModel = new Content();
		
		$categoryModel = new Category();
		
		$category = $categoryModel->createRow();
		$category->setName('New Category 5');

		$content = $contentModel->createRow();
		$content->setTitle('Title 6');
		$content->setContent('Content 6');
		$content->setIsActive(1);

		$category->setContent($content);

		$category->save();

		print '<pre>';
		var_dump($category->getData());
		die;
	}

	public function test2Action()
	{
		$contentModel = new Content();
		
		$categoryModel = new Category();
		
		$category = $categoryModel->createRow();
		$category->setName('Name Category 4');

		$content = $contentModel->createRow();
		$content->setTitle('Title 4');
		$content->setContent('Content 4');
		$content->setIsActive(1);

		$content->setCategory($category);
		$content->save();

		print '<pre>';
		var_dump($content->getData());
		die;
	}

	public function test1Action()
	{
		$contentModel = new Content();
		
		$categoryModel = new Category();
		
		$category = $categoryModel->findById(2);

		$content = $contentModel->createRow();
		$content->setTitle('Title 5');
		$content->setContent('Content 5');
		$content->setIsActive(1);

		$content->setCategory($category);
		$content->save();

		print '<pre>';
		var_dump($content->getData());
		die;
	}
}